package com.dome.mvp.uiview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;

/**
 * Time: 5/18/2021 10:55
 * Author: TAO
 * Description:
 */
public class NoScrollViewPage extends ViewPager {
    private boolean isSlidingEnable;

    public NoScrollViewPage(@NonNull Context context) {
        this(context, null);
    }

    public NoScrollViewPage(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }


    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return this.isSlidingEnable;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        return this.isSlidingEnable;
    }

    /**
     * 禁止滑动
     *
     * @param slidingEnable false禁止滑动 true可滑动
     */
    public void setSlidingEnable(boolean slidingEnable) {
        isSlidingEnable = slidingEnable;
    }
}
